﻿<UserControl x:Class="BaMusaSoft.RPS.View.CustomersView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:p="clr-namespace:BaMusaSoft.RPS.View.Properties"
             xmlns:wpfExtended="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
             Loaded="ViewLoaded" Unloaded="ViewUnloaded"
             mc:Ignorable="d" 
             d:DesignHeight="500" d:DesignWidth="500" FlowDirection="RightToLeft">
    <UserControl.Resources>
        <DataTemplate x:Key="CustomersList">
            <ListBox ItemsSource="{Binding}" IsSynchronizedWithCurrentItem="True" >
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <VirtualizingStackPanel/>
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Path=Name}"/>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </DataTemplate>

        <DataTemplate x:Key="CustomerDetails" >
            <Border BorderBrush="Silver" BorderThickness="1" Margin="16,10,10,10">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" MinHeight="36"/>
                        <RowDefinition Height="Auto" MinHeight="36"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" MinWidth="85"/>
                        <ColumnDefinition Width="0.541*"/>
                        <ColumnDefinition Width="Auto" MinWidth="88"/>
                        <ColumnDefinition Width="0.541*"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Grid.Column="0" Grid.Row="0" Text="{x:Static p:Resources.CustomerNoLabel}" Margin="0,12,4,2" TextAlignment="Right" VerticalAlignment="Top" />
                    <TextBlock Grid.Column="0" Grid.Row="1" Text="{x:Static p:Resources.CustomerNameLabel}" Margin="0,6,4,2" TextAlignment="Right" VerticalAlignment="Top"/>
                    <TextBlock Grid.Column="0" Grid.Row="2" Text="{x:Static p:Resources.CustomerIdNoLabel}" Margin="0,6,4,4" TextAlignment="Right" VerticalAlignment="Top"/>
                    <TextBlock Grid.Column="0" Grid.Row="3" Text="{x:Static p:Resources.CustomerIdDateLable}" Margin="0,6,4,4" TextAlignment="Right" VerticalAlignment="Top"/>
                    <TextBlock Grid.Column="0" Grid.Row="4" Text="{x:Static p:Resources.CustomerIdIssueLable}" Margin="0,6,4,4" TextAlignment="Right" VerticalAlignment="Top"/>
                    <TextBlock Grid.Column="0" Grid.Row="5" Text="{x:Static p:Resources.CustomerAddressLable}" Margin="0,6,4,4" TextAlignment="Right" VerticalAlignment="Top"/>
                    <TextBlock Grid.Column="2" Grid.Row="0" Text="{x:Static p:Resources.CustomerMainMobileLable}" Margin="0,12,4,4" TextAlignment="Right" VerticalAlignment="Top"/>
                    <TextBlock Grid.Column="2" Grid.Row="1" Text="{x:Static p:Resources.CustomerSecondMobileLable}" Margin="0,6,4,4" TextAlignment="Right" VerticalAlignment="Top"/>
                    <TextBlock Grid.Column="2" Grid.Row="2" Text="{x:Static p:Resources.CustomerHomePhoneLable}" Margin="0,6,4,4" TextAlignment="Right" VerticalAlignment="Top"/>
                    <TextBlock Grid.Column="2" Grid.Row="3" Text="{x:Static p:Resources.CustomerWorkPhoneLable}" Margin="0,6,4,4" TextAlignment="Right" VerticalAlignment="Top"/>
                    <TextBlock Grid.Column="2" Grid.Row="4" Text="{x:Static p:Resources.CustomerFaxLable}" Margin="0,6,4,4" TextAlignment="Right" VerticalAlignment="Top"/>
                    <TextBlock Grid.Column="2" Grid.Row="5" Text="{x:Static p:Resources.CustomerEmailLable}" Margin="0,6,4,4" TextAlignment="Right" VerticalAlignment="Top"/>
                    <TextBox Grid.Column="1" Grid.Row="0" Height="30" Text="{Binding Path=CustomerId, UpdateSourceTrigger=PropertyChanged}" Margin="4,10,2,4"/>
                    <TextBox Grid.Column="1" Grid.Row="1" Height="30" Text="{Binding Path=Name, UpdateSourceTrigger=PropertyChanged}" Margin="4,0,2,4"/>
                    <TextBox Grid.Column="1" Grid.Row="2" Height="30" Text="{Binding Path=IdNumber, UpdateSourceTrigger=PropertyChanged}" Margin="4,0,2,4" MaxLength="10"/>
                    <wpfExtended:MaskedTextBox Grid.Column="1" Grid.Row="3" IncludeLiterals="False" Mask="##/ ## / ####" 
                                               Value="{Binding Path=IdDate, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource DateConverter}}" Margin="4,0,2,4" Height="30"/>
                    <TextBox Grid.Column="1" Grid.Row="4" Height="30" Text="{Binding Path=IdIssue, UpdateSourceTrigger=PropertyChanged}" Margin="4,0,2,4" MaxLength="50"/>
                    <TextBox Grid.Column="1" Grid.Row="5" Height="150" Text="{Binding Path=Address, UpdateSourceTrigger=PropertyChanged}" Margin="4,0,2,4" MaxLength="200"/>
                    <wpfExtended:MaskedTextBox Grid.Column="3" Grid.Row="0" IncludeLiterals="False" Mask="(###)-#######"
                                               Value="{Binding Path=MainMobile, UpdateSourceTrigger=PropertyChanged}" Margin="4,10,5,4" Height="30" FlowDirection="LeftToRight"/>
                    
                    <wpfExtended:MaskedTextBox Grid.Column="3" Grid.Row="1" IncludeLiterals="False" Mask="(###)-#######"
                                               Value="{Binding Path=SecondMobile, UpdateSourceTrigger=PropertyChanged}" Margin="4,10,5,4" Height="30" FlowDirection="LeftToRight"/>
                    <wpfExtended:MaskedTextBox Grid.Column="3" Grid.Row="2" IncludeLiterals="False" Mask="(##)-#######"
                                               Value="{Binding Path=HomePhone, UpdateSourceTrigger=PropertyChanged}" Margin="4,10,5,4" Height="30" FlowDirection="LeftToRight"/>
                    <wpfExtended:MaskedTextBox Grid.Column="3" Grid.Row="3" IncludeLiterals="False" Mask="(##)-#######"
                                               Value="{Binding Path=WorkPhone, UpdateSourceTrigger=PropertyChanged}" Margin="4,10,5,4" Height="30" FlowDirection="LeftToRight"/>
                    <wpfExtended:MaskedTextBox Grid.Column="3" Grid.Row="4" IncludeLiterals="False" Mask="(##)-#######"
                                               Value="{Binding Path=Fax, UpdateSourceTrigger=PropertyChanged}" Margin="4,10,5,4" Height="30" FlowDirection="LeftToRight"/>
                    
                    <TextBox Grid.Column="3" Grid.Row="5" Height="30"  Text="{Binding Path=Email, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" 
                             VerticalAlignment="Top" Margin="4,0,5,2" MaxLength="100" FlowDirection="LeftToRight"/>
                </Grid>
            </Border>
        </DataTemplate>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot">
    	<Grid.RowDefinitions>
    		<RowDefinition Height="Auto"/>
			<RowDefinition Height="*"/>
			  	
		</Grid.RowDefinitions>
    	<Grid.ColumnDefinitions>
    		<ColumnDefinition Width=".50*"/>
			<ColumnDefinition />
		</Grid.ColumnDefinitions>
		<ToolBarTray Grid.ColumnSpan="2" Grid.Row="0">
			<ToolBar>
				<Button Content="Save" Command="{Binding Path=SaveCommand}"/>
			</ToolBar>
		</ToolBarTray>

        <Grid x:Name="customersListRegion" Grid.Column="0" Grid.Row="1">
            <Border Margin="0,10,0,10">
                <DockPanel>
                    <TextBox DockPanel.Dock="Top" Text="{Binding Path=CustomerName, UpdateSourceTrigger=PropertyChanged}" 
                             ToolTip="{x:Static p:Resources.SearchHintToolTip}" Height="28" Margin="0,0,0,5" />
                    <ContentControl Content="{Binding Path=Customers}" ContentTemplate="{StaticResource CustomersList}"/>
                </DockPanel>
            </Border>
        </Grid>
        <Grid x:Name="customerDetailsRegion" Grid.Column="1" Grid.Row="1">
            <ContentControl Content="{Binding Path=SelectedCustomer}" ContentTemplate="{StaticResource CustomerDetails}" />
        </Grid>
    </Grid>
</UserControl>
